Basic analysis of Vancouver weather patterns:
Data is collected from Govt of Canada website:
(process is automated in ‘van-weather-import.R’)
## [1] "Winter" "Spring" "Summer" "Fall"
Earliest date: 1970-01-01
Most recent date: 2021-01-08
`
Check data structure and summary:
## tibble [18,635 x 11] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ Month : Factor w/ 12 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Season : Factor w/ 4 levels "Winter","Spring",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Date : Date[1:18635], format: "1970-01-01" "1970-01-02" ...
## $ Year : Factor w/ 52 levels "1970","1971",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Day : num [1:18635] 1 2 3 4 5 6 7 8 9 10 ...
## $ Max.Temp : num [1:18635] 6.1 2.2 5 2.8 1.7 5.6 3.3 4.4 7.2 5.6 ...
## $ Min.Temp : num [1:18635] -1.7 0 -1.7 -3.3 -2.8 -1.7 -3.3 0 2.8 -2.8 ...
## $ Mean.Temp : num [1:18635] 2.2 1.1 1.7 -0.3 -0.6 2 0 2.2 5 1.4 ...
## $ Total.Precip: num [1:18635] 0 1 0.5 0 0 0 0 4.6 6.6 0.5 ...
## $ Season.Yr : num [1:18635] 1970 1970 1970 1970 1970 1970 1970 1970 1970 1970 ...
## $ station : chr [1:18635] "VANCOUVER INT'L A" "VANCOUVER INT'L A" "VANCOUVER INT'L A" "VANCOUVER INT'L A" ...
## - attr(*, "spec")=
## .. cols(
## .. Month = col_double(),
## .. Season = col_character(),
## .. Date = col_date(format = ""),
## .. Year = col_double(),
## .. Day = col_double(),
## .. Max.Temp = col_double(),
## .. Min.Temp = col_double(),
## .. Mean.Temp = col_double(),
## .. Total.Precip = col_double(),
## .. Season.Yr = col_double(),
## .. station = col_character()
## .. )
## Month Season Date Year
## 1 :1589 Winter:4610 Min. :1970-01-01 1972 : 366
## 3 :1581 Spring:4692 1st Qu.:1982-10-03 1976 : 366
## 5 :1581 Summer:4692 Median :1995-07-07 1980 : 366
## 7 :1581 Fall :4641 Mean :1995-07-06 1984 : 366
## 8 :1581 3rd Qu.:2008-04-07 1988 : 366
## 10 :1581 Max. :2021-01-08 1992 : 366
## (Other):9141 (Other):16439
## Day Max.Temp Min.Temp Mean.Temp
## Min. : 1.00 Min. :-8.70 Min. :-15.200 Min. :-11.5
## 1st Qu.: 8.00 1st Qu.: 8.90 1st Qu.: 2.800 1st Qu.: 6.0
## Median :16.00 Median :13.30 Median : 6.800 Median : 10.0
## Mean :15.72 Mean :13.84 Mean : 6.711 Mean : 10.3
## 3rd Qu.:23.00 3rd Qu.:19.00 3rd Qu.: 11.300 3rd Qu.: 15.2
## Max. :31.00 Max. :34.40 Max. : 22.400 Max. : 28.4
## NA's :52 NA's :45 NA's :54
## Total.Precip Season.Yr station
## Min. : 0.000 Min. :1970 Length:18635
## 1st Qu.: 0.000 1st Qu.:1982 Class :character
## Median : 0.000 Median :1995 Mode :character
## Mean : 3.228 Mean :1995
## 3rd Qu.: 3.600 3rd Qu.:2008
## Max. :91.600 Max. :2021
## NA's :54
Check Data Relationships
For each month, what has been the pattern in precipitation over the years?
Note: the year for a winter season is applied to year at end of season. So winter from Dec 2018 to Feb 2019 is considered winter of 2019.
##
## Call:
## lm(formula = mean.mean ~ ynum, data = vw.temp.yr)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.11837 -0.35274 -0.08088 0.36937 0.97701
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -40.987746 9.420792 -4.351 6.87e-05 ***
## ynum 0.025708 0.004722 5.444 1.66e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4964 on 49 degrees of freedom
## Multiple R-squared: 0.3769, Adjusted R-squared: 0.3642
## F-statistic: 29.64 on 1 and 49 DF, p-value: 1.659e-06
Model interpretation:
Linear modelling for max and min
##
## Call:
## lm(formula = mean.max ~ ynum, data = vw.temp.yr)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.93114 -0.31913 0.04793 0.35363 1.05197
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -27.048385 9.663318 -2.799 0.007310 **
## ynum 0.020496 0.004844 4.232 0.000101 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5092 on 49 degrees of freedom
## Multiple R-squared: 0.2676, Adjusted R-squared: 0.2527
## F-statistic: 17.91 on 1 and 49 DF, p-value: 0.0001014
Model interpretation:
##
## Call:
## lm(formula = mean.min ~ ynum, data = vw.temp.yr)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.30263 -0.31189 0.01655 0.40452 1.11209
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -54.893664 9.779701 -5.613 9.18e-07 ***
## ynum 0.030880 0.004902 6.300 8.07e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5153 on 49 degrees of freedom
## Multiple R-squared: 0.4475, Adjusted R-squared: 0.4362
## F-statistic: 39.68 on 1 and 49 DF, p-value: 8.07e-08
Model interpretation:
For each month, what has been the pattern in ave. temperature over the years?
Note: the year for a winter season is applied to year at end of season. So winter from Dec 2018 to Feb 2019 is considered winter of 2019.